import komand
from .schema import DeleteUserInput, DeleteUserOutput
# Custom imports below
from komand_rapid7_insightvm.util import endpoints
from komand_rapid7_insightvm.util.resource_helper import ResourceHelper


class DeleteUser(komand.Action):

    def __init__(self):
        super(self.__class__, self).__init__(
                name='delete_user',
                description='Delete an user account',
                input=DeleteUserInput(),
                output=DeleteUserOutput())

    def run(self, params={}):
        resource_helper = ResourceHelper(self.connection.session, self.logger)
        endpoint = endpoints.User.users(self.connection.console_url, params.get('id'))
        self.logger.info("Using %s ..." % endpoint)

        # Get the existing details so the specific role ID key can be modified
        response = resource_helper.resource_request(endpoint=endpoint, method='delete')

        return response
